<?php
 @session_start();
 require '../ArqCnCli.php';
 $cnpj=trim($_POST['cnpj']); 
 $val = trim($_POST['val']);
 $md5 = trim($_POST['md5']);
 $email=trim($_POST['email']);
 $md5cal=strtoupper(md5($cnpj.$email.$val.'liteciaugusto'));		
 if ($md5cal==$md5){
     $select = "select * from tbsngpc where cnpj =$cnpj";
     $query = mysql_query($select);
     if (mysql_num_rows($query)==0) {
        $select="insert into tbsngpc(cnpj,email,data,hora,ativo)values('".$cnpj."','".$email."',current_date,current_time,'S')";
        mysql_query($select);
     }else{
         $select="update tbsngpc set data=Current_date,hora=Current_time where cnpj=$cnpj";
         mysql_query($select);
     }        
 };
?>
